<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Cache-Control"  content="no-transform">
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>用户登录</title>
    <link href="/statics/view/css/shop_common.css" rel="stylesheet" type="text/css" />
    <link href="/statics/view/css/shop_layout.css" rel="stylesheet" type="text/css" />
    <script src="//cdn.bootcss.com/jquery/2.1.0/jquery.min.js"></script>
    <script src="/statics/view/js/db.js"></script>
    <script type="text/javascript" src="/statics/view/js/common.js"></script>
    <script type="text/javascript" src="/statics/view/js/jquery.validate.js"></script>
    <script type="text/javascript" src="/statics/layer.m/layer.m.js"></script>
    <script type="text/javascript">
        $().ready(function() {
            var $loginForm = $("#loginForm");
            var $username = $("#username");
            var $smsCode = $("#smsCode");

            // 表单验证
            $loginForm.validate({
                rules: {
                    username: "required",
                    smsCode: "required"
                },
                submitHandler: function(form) {
                    layer.open({
                        type: 2,
                        content: '登陆中~'
                    });
                    if($("#user-login").hasClass("disabled")){
                        return false;
                    }
                    $("#user-login").addClass("disabled");
                    $.ajax({
                        url: $loginForm.attr("action"),
                        type: "POST",
                        data: {
                            username: $username.val(),
                            smsCode : $smsCode.val()
                        },
                        dataType: "json",
                        cache: false,
                        success: function(message) {
                            layer.closeAll();
                            $("#user-login").removeClass("disabled");
                            if (message.type == "success") {
                            [#if redirectUrl??]
                                location.href = "${redirectUrl}";
                            [#else]
                                location.href = "/";
                            [/#if]
                            } else {
                                layer.open({
                                    content: message.content,
                                    time: 2
                                });
                            }
                        },error:function(){
                            $("#user-login").removeClass("disabled");
                            layer.closeAll();
                            layer.open({
                                content: "服务器异常",
                                time: 2
                            });
                        }
                    });
                }
            });
        });
    </script>
</head>
<body>
<header id="header" class="u-header clearfix">
    <div class="u-hd-left f-left"><a href="/dbs/index.html" class="J_backToPrev"><span class="u-icon-px i-hd-back"></span></a></div>
    <span class="u-hd-tit">用户登录</span>
    <div class="u-hd-right f-right"><a href="/db" mars_sead="nav_home_btn"><span class="u-icon-px i-hd-home"></span></a></div>
</header>
<div class="container user-login-box">
    <div class="row">
        <div class="panel panel-forms" id="panel-forms-login">
            <!-- 登录 -->
            <div class="panel-body" data-validform="loginForm">
               <form action="/wapMobileLogin"  method="post" id="loginForm">
                   <ul class="nav nav-list form form-horizontal">
                       <li class="control-group">
                           <label class="control-label" for="inputName">账号：</label>
                           <div class="controls">
                               <input name="username" id="username" type="text" value="" maxlength="50" placeholder="请输入手机号码" data-placeholder="请输入手机号码" datatype="m|e|q">
                           </div>
                           <a href="javascript:;" class="i-delete-text btn-delete" mars_sead="login_delnum_btn"><i class="i-icon-remove"></i></a>
                       </li>
                       <li class="control-text validform-tips"></li>
                       <li class="control-group control-captcha" id="li_captcha">
                           <span><input type="text" id="smsCode" name="captcha" size="6" maxlength="6" style="width: 120px;"  placeholder="6位手机验证码" value=""></span>
                           <a href=""  id="getCode" data-type="wapLogin">&nbsp;获取验证码</a>
                       </li>
                       <li class="control-text validform-tips"></li>
                   </ul>
                   <div class="btn-controls">
                       <button type="submit" class="btn btn-long btn-purple disabled" data-action="loginCheck" id="user-login">登 录</button>
                   </div>
               </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function loadNL(){
        $.ajax({
            url: "/wo/unikey",
            type: "GET",
            dataType: "json",
            cache: false,
            success: function(data) {
                $.ajax({
                    url: "/wo/nl",
                    type: "GET",
                    dataType: "json",
                    data: {unikey: data.content},
                    cache: false,
                    success: function(data) {
                        if(data.type=='success'){
                           [#if redirectUrl??]
                             location.href = "${redirectUrl}";
                          [#else]
                              location.href = "/";
                          [/#if]
                        }
                    },error:function(){}
                });
            },error:function(data){}
        });
    }
    loadNL();
</script>
</body>
</html>